package com.yape.controller;

import com.yape.stockService.IChinaIndexService;
import com.yape.response.Response;
import com.yape.vo.ChinaIndexVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author yape
 * @description
 * @date 2025/5/24 20:59
 */
@RestController
@RequestMapping("/api/indices/")
@CrossOrigin("*")    // 跨域
@Slf4j
public class ChinaIndexController {

    @Resource
    private IChinaIndexService chinaIndexService;

    @GetMapping("latest")
    public Response<ChinaIndexVO> getChinaIndex(@RequestParam int page,@RequestParam int size) {
        log.info("获取中国指数列表，第{}页，每页数量{}", page, size);
        ChinaIndexVO chinaIndexVO = chinaIndexService.queryChinaIndexList(page, size);
        return Response.<ChinaIndexVO>builder()
                .code("200")
                .message("success")
                .data(chinaIndexVO)
                .build();
    }
}
